cmake_minimum_required(VERSION 2.8.12)
project (wuppertools)

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --pedantic -Wall -fPIC -DUSE_LIB_CMEM")


include_directories("." "../drivers/" "../rcc_error/" "../DFDebug" "../regmap")

set(CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG_LEVEL=1")

set(CMAKE_BUILD_TYPE Debug)

add_subdirectory(../drivers ./drivers)
add_subdirectory(../regmap ./regmap)

add_library(Wupper STATIC src/WupperCard.cpp src/WupperException.cpp )
target_link_libraries (Wupper regmap rt cmem_rcc DFDebug rcc_error)

add_executable(wupper-reset src/wupper-reset.cpp)
target_link_libraries (wupper-reset Wupper)

add_executable(wupper-config src/wupper-config.cpp)
target_link_libraries (wupper-config Wupper)

add_executable(wupper-dma-transfer src/wupper-dma-transfer.cpp)
target_link_libraries (wupper-dma-transfer Wupper)

add_executable(wupper-dump-blocks src/wupper-dump-blocks.cpp)
target_link_libraries (wupper-dump-blocks Wupper)

add_executable(wupper-throughput src/wupper-throughput.cpp)
target_link_libraries (wupper-throughput Wupper)

add_executable(wupper-info src/wupper-info.cpp)
target_link_libraries (wupper-info Wupper)

add_executable(wupper-irq-test src/wupper-irq-test.cpp)
target_link_libraries (wupper-irq-test Wupper pthread)

add_executable(wupper-dma-stat src/wupper-dma-stat.cpp)
target_link_libraries (wupper-dma-stat Wupper)

add_executable(wupper-wishbone src/wupper-wishbone.cpp)
target_link_libraries (wupper-wishbone Wupper)

# Stuff for this project
include_directories(libwtools/)

# Wtools library
file(GLOB LIBWTOOLS_SOURCES libwtools/*.cpp)
add_library(LibWTools ${LIBWTOOLS_SOURCES})
target_link_libraries(LibWTools Wupper)

add_executable(wdaq src/wdaq.cpp)
target_link_libraries(wdaq Wupper LibWTools)

add_executable(wdaqm src/wdaqm.cpp)
target_link_libraries(wdaqm Wupper LibWTools)

add_executable(wfile src/wfile.cpp)
target_link_libraries(wfile Wupper LibWTools)

add_executable(wpepo src/wpepo.cpp)
target_link_libraries(wpepo Wupper LibWTools)

